package com.hmkj.core.service.system.impl;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.core.exception.BussinessException;
import com.hmkj.core.mapper.system.BankMapper;
import com.hmkj.core.po.system.Bank;
import com.hmkj.core.service.system.BankService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 系统配置的银行列表业务相关Service接口实现<br>
 *
 * @author donfy
 * @ClassName: BankServiceImpl
 * @date 2017-08-15 08:55:41
 */
@Service
@Scope("prototype")
@Transactional(rollbackFor = Exception.class)
public class BankServiceImpl implements BankService {

    @Resource
    private BankMapper bankMapper;

    @Override
    public GenericMapper<Bank,Integer> _getMapper() {
        return bankMapper;
    }

    @Override
    public List<Bank> selectByIds(String ids) {
        Map<String, Object> params  = new HashMap<>();
        params.put("ids",ids);
        return bankMapper.selectByIds(params);
    }

    @Override
    public String jbpBankMapping(String insideCode) {
        switch (insideCode) {
            case "2":
                return "1";
            case "10":
                return "2";
            case "7":
                return "3";
            case "3":
                return "4";
            case "1":
                return "5";
            case "4":
                return "6";
            case "12":
                return "7";
            case "17":
                return "8";
            case "8":
                return "9";
            case "11":
                return "10";
            case "19":
                return "11";
            case "28":
                return "12";
            case "14":
                return "13";
            case "18":
                return "14";
            case "13":
                return "15";
            default:
                throw new BussinessException("当前支付通道不支持该银行类型");
        }
    }

}
